package com.ruoyi.quartz.util;




import sun.misc.BASE64Decoder;
import sun.misc.BASE64Encoder;

import java.util.Date;

public class SignUtil {
    public static String getSign(String appId, String apiKey){
        Date date = new Date();
        long timestamp = date.getTime();  //13位的当前时间戳
        String param = "appId="+appId + "&apiKey="+apiKey+"&timestamp="+timestamp;
        String sign = null;
        try {
            sign = encryptBASE64(param.getBytes());
        } catch (Exception e) {
            e.printStackTrace();
        }

        return sign;
    }
    /**
     * BASE64解密
     * @throws Exception
     */
    public static byte[] decryptBASE64(String key) throws Exception {
        return (new BASE64Decoder()).decodeBuffer(key);
    }

    /**
     * BASE64加密
     */
    public static String encryptBASE64(byte[] key) throws Exception {
        return (new BASE64Encoder()).encodeBuffer(key);
    }





}

